/*
 * @Date: 2023-02-15 16:07:01
 * @LastEditTime: 2023-02-23 11:43:28
 * @FilePath: /hash-guess-game/src/api/module/sys.ts
 * 介绍:系统接口,公共接口
 */
import { defaHttp, ApiRes, ApiReturn } from "../index";
import type { CoinEnum } from "@@/store/useBalanceStore";

/**登录 */
export async function apiLogin(data: Login.Req): ApiReturn<Login.Res> {
  const res = await defaHttp.post<ApiRes<Login.Res>>("/connect", data, {
    mode: ["removeReqVoid", "showError", "showSucceed", "showLoading"],
  });
  if (res.code !== 200) return;
  return res.data;
}

/**登录 */
export namespace Login {
  export interface Req {
    /**客户端ID */
    clientId: Id;
    /**56是BSC；99 是SOLANA地址;100是TRON地址 */
    chainId: Id;
    nwtworkId: Id;
    /**用户地址 */
    accounts: string;
    /**邀请码 */
    invit?: string;
    /**当前钱包名 */
    that_wallet_name: string;
  }
  export interface Res {
    access_token: string;
    token_type: string;
    expires_in: number;
  }
}
/**币种枚举 */
export async function apiCoinlist(): ApiReturn<Coinlist.ResItem[]> {
  const res = await defaHttp.post<ApiRes<Coinlist.ResItem[]>>(
    "/get/coinlist",
    undefined,
    {
      mode: ["showError"],
    }
  );
  if (res.code !== 200) return;
  return res.data;
}
export namespace Coinlist {
  export type Req = void;
  export interface ResItem extends CoinEnum {}
}

/**赛级规则 */
export async function apiGameRule(): ApiReturn<unknownObj> {
  const res = await defaHttp.post<ApiRes<unknownObj>>(
    "/active/set",
    undefined,
    {
      mode: ["showError"],
    }
  );
  if (res.code !== 200) return;
  return res.data;
}
export namespace GameRule {
  export type Req = void;
  /**key为等级 */
  export interface ResItem {
    /**金额 */
    min: StrNumber;
    max: StrNumber;
    /**比例 */
    bili: StrNumber;
  }
}
